import http from "@/utils/http.ts";
import {R} from "@/api/common.ts";

enum Router {
    range = "table/range",
    current = "table/current",
    add = "table/add",
}

export interface TableRange {
    tableName: string;
    from: string;
    to: string;
    size: string;
}

export function getRange() {
    return http<R<TableRange[]>>({
        url: Router.range,
        method: 'get',
    })
}

export function getCurrentTable() {
    return http<R<null>>({
        url: Router.current,
        method: 'get',
    })
}

export function add(tableName: string) {
    return http<R<null>>({
        url: `${Router.add}/${tableName}`,
        method: 'get',
    })
}

export function getTableCount(tableName: string) {
    return http<R<string>>({
        url: `table/count/${tableName}`,
        method: 'get',
    })
}